﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity.Infrastructure;
using DLM.Domain.Model;

namespace DLM.Data.EF.CodeFirst.Mapping
{
    public class UserMap : EntityTypeConfiguration<User>
    {
        public UserMap()
        {
            this.HasKey(t => t.UserID);
            this.ToTable("User");
            this.Property(t => t.UserID).HasColumnName("UserID");
            this.Property(t => t.AccountID).HasColumnName("AccountID");
            this.Property(t => t.AccountName).HasColumnName("AccountName").IsRequired().HasMaxLength(25);
            this.Property(t => t.Name).HasColumnName("Name").HasMaxLength(20);
            this.Property(t => t.Gender).HasColumnName("Gender");
            this.Property(t => t.Birthday).HasColumnName("Birthday");
            this.Property(t => t.Age).HasColumnName("Age");
            this.Property(t => t.Location).HasColumnName("Location").IsUnicode(true).HasMaxLength(20);
            this.Property(t => t.HomePlace).HasColumnName("HomePlace").HasMaxLength(30);
            this.Property(t => t.Marriage).HasColumnName("Marriage").HasMaxLength(8);
            this.Property(t => t.NativePlace).HasColumnName("NativePlace").HasMaxLength(40);
            this.Property(t => t.Stature).HasColumnName("Stature").HasMaxLength(10);
            this.Property(t => t.Weight).HasColumnName("Weight");
            this.Property(t => t.Education).HasColumnName("Education").HasMaxLength(10);
            this.Property(t => t.Job).HasColumnName("Job").HasMaxLength(20);
            this.Property(t => t.Income).HasColumnName("Income").HasMaxLength(15);
            this.Property(t => t.Position).HasColumnName("Position").HasMaxLength(20);
            this.Property(t => t.Industry).HasColumnName("Industry").HasMaxLength(50);
            this.Property(t => t.Car).HasColumnName("Car").HasMaxLength(10);
            this.Property(t => t.Parents).HasColumnName("Parents").HasMaxLength(20);
            this.Property(t => t.Photo).HasColumnName("Photo").HasMaxLength(50);
            this.Property(t => t.Phone).HasColumnName("Phone").IsUnicode(false).HasMaxLength(15);
            this.Property(t => t.IM).HasColumnName("IM").IsUnicode(false).HasMaxLength(18);
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.Property(t => t.IsValidation).HasColumnName("IsValidation");
            this.Property(t => t.Introduction).HasColumnName("Introduction").HasMaxLength(300);
            this.HasRequired(t => t.Account).WithMany(t => t.Users).HasForeignKey(d => d.AccountID);
        }
    }
}
